<?php
$this->Html->css('controllers/Trainings/evaluations.css?1', array('block' => 'stylesTop'));
$this->Html->script('controllers/Trainings/evaluations.js?2', array('block' => 'scriptBottom'));
$appBosch->crud = $this->TioCachas->urlsCRUD();
$appBosch->urlDetails = $this->Html->url(array('action' => 'getDetails'));
$appBosch->iTrainings = 1;
$appBosch->urlUserAttempts = $this->Html->url(array('controller' => 'Attempts', 'action' => 'getAttemptsDetails'));
$appBosch->urlEvaluationdetails = $this->Html->url(array('controller' => 'Evaluations', 'action' => 'getDetails'));
$appBosch->urlDiploma = $this->Html->url(array('action'=>'diploma'));
?>
<script id="templateProximos" type="text/kendo-template">
    #if(proximos == 1 ){#
    <i class='fa fa-clock-o proximo' style="color:red; font-size:3rem; display:block; text-align:center;"
       title='<?php echo __('certificación en proceso próxima a caducar'); ?>'</i>
    #}#
</script>

<?php if (count($appBosch->data) != 0) { ?>
    <div id="grid"></div>
<?php } else { ?>
    <div class="alert alert-warning">
        <?php echo __('Aun no se ha iniciado ningún curso. Se puede inscribir a algún curso por medio de la opción '); ?>
        <a href="<?php echo $this->Html->url(array('controller' => 'TestRegister', 'action' => 'admin')); ?>">Inscripciones</a><?php echo __(' del menú Cursos'); ?>
    </div>
<?php } ?>

    <script id="windowTemplate" type="text/x-kendo-template">
        # var max = 0; #
        <div>
            <h4><?php echo __('Historial de intentos'); ?></h4>

            <div class="historial">
                <table class="table table-bordered table-condensed table-hover">
                    <thead>
                    <tr>
                        <th><?php echo __('Calificación'); ?></th>
                        <th><?php echo __('Fecha de aplicación'); ?></th>
                    </tr>
                    </thead>
                    <tbody>
                    # if (res.length == 0) { #
                    <tr>
                        <td><?php echo __('No hay intentos'); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo __(''); ?></td>
                    </tr>
                    # } #
                    # for (var i = 0; i < res.length; i++) {
                    if (parseFloat(res[i].qualification) > parseFloat(max)) {
                    max = res[i].qualification;
                    }
                    if (parseFloat(res[i].qualification) < parseFloat(res[i].min_cal)) { #
                    <tr class="reprobado danger">
                        # } else { #
                    <tr class="">
                        # } #
                        <td>#= res[i].qualification #</td>
                        # var dD = res[i].application_date != null ? kendo.toString(new Date(res[i].application_date.replace(/-/g, '/')), 'D') : '<?php echo __('Sin fechar'); ?>';
                          var dd = res[i].application_date != null ? kendo.toString(new Date(res[i].application_date.replace(/-/g, '/')), 'd') : '<?php echo __('Sin fechar'); ?>'; #
                        <td title="#= dD #">
                            #= dd #
                        </td>
                    </tr>
                    # } #
                    </tbody>
                </table>
            </div>
        </div>
    </script>

    <script id="windowTemplateDetails" type="text/x-kendo-template">
        # var max = 0; #
        <div>
            <h4><?php echo __('Detalles de la evaluación'); ?></h4>

            <div class="historial">
                <table class="table table-bordered table-condensed table-hover">
                    <thead>
                    <tr>
                        <th><?php echo __('Tema'); ?></th>
                        <th><?php echo __('Calificación'); ?></th>
                    </tr>
                    </thead>
                    <tbody>
                    # if (res.length == 0) { #
                    <tr>
                        <td><?php echo __('No hay detalles'); ?></td>
                    </tr>
                    <tr>
                        <td><?php echo __(''); ?></td>
                    </tr>
                    # } #
                    # for (var i = 0; i < res.length; i++) {
                    if (parseFloat(res[i].cal) > parseFloat(max)) {
                    max = res[i].cal;
                    }
                    if (parseFloat(res[i].cal) < parseFloat(res[i].min_cal)) { #
                    <tr class="reprobado danger">
                        # } else { #
                    <tr>
                        # } #
                        <td>#= res[i].theme #</td>
                        <td>#= res[i].cal #</td>
                    </tr>
                    # } #
                    </tbody>
                </table>
            </div>
        </div>
    </script>

<a id="magicLink" class="hidden"></a>

<?php $this->start('jsVars'); ?>
    <script type="text/javascript">
        var appBosch = <?php echo json_encode($appBosch); ?>;
    </script>
<?php $this->end();